import QtQuick 2.15
import QtWebSockets 1.15
import QtQuick.Controls 2.15
Rectangle {
    anchors.fill: parent
    color: "#f5f5f5"
    property string msg :"";

    Rectangle{
        id:boxe
        height:100
        width:300
        anchors.top: parent.top
        clip:true
        border.color: "black"

        TextInput{
            height:100
            width:300
            font.pixelSize: 30
            wrapMode: Text.WordWrap
            id:sendeText
            text:msg
        }

    }
    Rectangle{
        id:box
        height:100
        width:300
        anchors.centerIn: parent
        clip:true
        border.color: "black"

        TextInput{
            height:100
            width:300
            font.pixelSize: 30
            wrapMode: Text.WordWrap
            id:sendText
        text:"asdsadasd"

        }
    }




    Button {
        anchors.verticalCenter:parent.verticalCenter
        anchors.left: box.right

        id: control
        text: qsTr("Button")

        contentItem: Text {
            text: control.text
            font: control.font
            opacity: enabled ? 1.0 : 0.3
            color: control.down ? "#17a81a" : "#21be2b"
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            elide: Text.ElideRight
        }

        background: Rectangle {
            implicitWidth: 100
            implicitHeight: 40
            opacity: enabled ? 1 : 0.3
            border.color: control.down ? "#17a81a" : "#21be2b"
            border.width: 1
            radius: 2
            MouseArea{
                anchors.fill: parent
                hoverEnabled: true
                onClicked: {
                    chatServer.sedMessage(10002,"测试昵称",111,1,111,"msgId测试","17760659134",sendText.text,"消息来自金箍棒",111)
                }
            }
        }
    }

    WebService{
        id:chatServer
        onTextMessageReceived: function(message){
            console.log(message)
          var E=JSON.parse(message)
            msg=msg+E.msgcontent
        }
    }

    Component.onCompleted: {

        console.log("真正的聊天主页面")

    }
}
